local room = {}

room.state = 
{
    playing_players = {};
}

room.actions = 
{

}

room.mutations = 
{
    on_enter = function(store, state, player)
        if player.seat.no > 0 then
            state.playing_players[player.seat.no] = player;
            store.emit("玩家进入", player);
        end
    end,

    on_leave = function(store, state, player)
        for no, playing_player in pairs(state.playing_players) do
            if playing_player == player then
                state.playing_players[no] = nil;
                player.seat.no = no;
                store.emit("玩家离开", player);    
                break;
            end
        end
    end,

    on_set_chip = function(store, state, args)
        store.emit("筹码变更", args);
    end
}

return room